<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<script>
// var arr=[1,2,3,4,1,2,3];
// var arr2=[];
// for(var i=0;i<arr.length;i++){
//     if(arr2.indexOf(arr[i])==-1){
//         arr2.push(arr[i])
//     }
// }
// console.log(arr2)
var arr=[1,5,2,4,9,3,6];
function sort(arr){
    if(arr.length<=1){return arr}
    var ban=Math.floor(arr.length/2);
    var aban=arr.splice(ban,1)[0];
    var left=[];
    var right=[];
    for(var i=0;i<arr.length;i++){
        if(aban>=arr[i]){
            left.push(arr[i])
        }else{
            right.push(arr[i])
        }
    }
    return sort(left).concat(aban,sort(right))
}
console.log(sort(arr))
</script>    
</body>
</html>